package counter;

import main.Main;

public class CounterThread extends Thread {

	private ICounter _counter;
	
	/**
	 * C'tor
	 * @param counter The shared counter obj.
	 */
	public CounterThread(ICounter counter) {
		_counter = counter;
	}

	@Override
	public void run() {
		int cachedVal;
		int countTo = Main.getCountTo();
		for (int iterNum = 0; iterNum < countTo ; iterNum++) {
			cachedVal = _counter.getValue();
			cachedVal++;
			_counter.setValue(cachedVal);
		}
	}
}
